<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$youmid=0;
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$return['ischecklogin']=cfc('core')->checklogin('','',true);
	if($_SESSION['uid']){
		$this->model('model')->upmember();
		if($youmid==$_SESSION['uid']){
			$youmid=0;
		}
		$this->model('model')->jiesuan();
	}
	$_SESSION['youmid']=$youmid;
	if(substr($return['pluginset']['shoplink'],-1)=='/' && substr($return['pluginset']['shoplink'],-2)!='//'){
		$return['pluginset']['shoplink'] .='/';
	}
	$return['pluginset']['shoplink']=$return['pluginset']['shoplink']?:'jy_weishop/index//';
	$return['pluginset']['shoplink'].='&plugin_name=jy_yangjidan';
	if($youmid){
		$this->model('model')->up_looklog($youmid);
		$return['youmid']=$youmid;
		$member=model('core/member')->detail($youmid,array('credit1','credit2','mobile','avatar','nickname'));
		$newmember=$this->pdo_get('member',array('mid'=>$youmid,'uniacid'=>$_SESSION['uniacid']));
		$return['member']=array_merge($member,$newmember);
		if($return['member']['myji']>0){
			$return['jitips']='好友目前已认养'.$return['member']['myji'].'只蛋鸡，健康蛋鸡'.$return['member']['myji1'].'只！';
		}else{
			$return['jitips']='好友目前还未认养蛋鸡，去通知好友前往兑换或购买《蛋鸡》吧！';
		}
	}else{
		$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','mobile','avatar','nickname'));
		$newmember=$this->pdo_get('member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
		$return['member']=array_merge($member,$newmember);
		$isgetcv_dayfee=$this->pdo_get('cvlog',array('type'=>2,'createtime >'=>$daytime,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
		if($isgetcv_dayfee){
			$renwu['cv_renwu2']=1;
		}
		$isgetcv_dayfee=$this->pdo_get('cvlog',array('type'=>5,'createtime >'=>$daytime,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
		if($isgetcv_dayfee){
			$renwu['cv_renwu5']=1;
		}
		$isgetcv_dayfee=$this->pdo_get('cvlog',array('type'=>6,'createtime >'=>$daytime,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
		if($isgetcv_dayfee){
			$renwu['cv_renwu6']=1;
		}
		$renwu['looklognum']=$this->pdo_count('looklog',array('createtime >'=>$daytime,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
		$return['renwu']=$renwu;
	}
	$return['member']['haoyounum']=pdo_count('core_members',array('fromuser'=>$youmid?:$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['member']['noweiji']=$this->pdo_count('myji',array('isweitou'=>0,'status'=>array(1,2),'mid'=>$youmid?:$_SESSION['uid'],'weitime <'=>$daytime,'uniacid'=>$_SESSION['uniacid']));
	$return['member']['isweiji']=$this->pdo_count('myji',array('status'=>1,'mid'=>$youmid?:$_SESSION['uid'],'weitime >'=>$daytime,'uniacid'=>$_SESSION['uniacid']));
	$return['member']['myji1']=$this->pdo_count('myji',array('status'=>1,'mid'=>$youmid?:$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['member']['myji']=$this->pdo_count('myji',array('mid'=>$youmid?:$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if($return['member']['myji']>0){
		$return['jitips']='您目前已认养'.$return['member']['myji'].'只鸡，健康鸡'.$return['member']['myji1'].'只！';
	}else{
		$return['jitips']='目前还未认养蛋鸡，可以前往租养或认养《鸡苗/蛋鸡》！';
	}
	$return['params']=array('jy'=>1);
	if(!$youmid){
		$yuetime= mktime(0,0,0,date('m'),1,date('Y'));
		$allfee0=$this->model('model')->getyeji($_SESSION['uid'],0);
		$allfee1=$this->model('model')->getyeji($_SESSION['uid'],1);
		$isa0=$allfee0>$allfee1?1:0;
		$isa1=$isa0?0:1;
		if($allfee0>$allfee1){
			$return['fansqun']['allfee0']=$allfee1;
			$return['fansqun']['allfee1']=$allfee0;
		}else{
			$return['fansqun']['allfee0']=$allfee0;
			$return['fansqun']['allfee1']=$allfee1;
		}
		$return['fansqun']['dayfee0']=$this->model('model')->getyeji($_SESSION['uid'],$isa0,$daytime);
		$return['fansqun']['yuefee0']=$this->model('model')->getyeji($_SESSION['uid'],$isa0,$yuetime);
		$return['fansqun']['dayfee1']=$this->model('model')->getyeji($_SESSION['uid'],$isa1,$daytime);
		$return['fansqun']['yuefee1']=$this->model('model')->getyeji($_SESSION['uid'],$isa1,$yuetime);
		$return['cvlog']['allcv']=$return['member']['allcv'];
		$return['cvlog']['cv3']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>3,'uniacid'=>$_SESSION['uniacid']),'fee');
		$return['cvlog']['cancv']=$return['member']['cv']+$return['cvlog']['cv3'];
		$return['cvlog']['iscv']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'isadd'=>0,'uniacid'=>$_SESSION['uniacid']),'fee');
		$return['cvlog']['cv4']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>4,'uniacid'=>$_SESSION['uniacid']),'fee');
		$return['cvlog']['cv0']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>0,'uniacid'=>$_SESSION['uniacid']),'fee');
		$return['cvlog']['cv1']=pdo_getsum('jy_yangjidan_cvlog',array('mid'=>$_SESSION['uid'],'status'=>1,'uniacid'=>$_SESSION['uniacid']),'fee');
		$return['member']['jmdanbei']=intval($return['member']['jd']/30);
		$return['member']['jmdan']=$return['member']['jmdanbei']*30;
		$return['member']['jmprice']=$return['member']['jmdanbei']*$this->setting['dj_saleprice'];
		$return['member']['jiefee']=$this->model('model')->checkjiefee(0,true);
		$return['member']['alljiefee']=pdo_getsum('jy_yangjidan_feelog',array('jiefee'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'price');
		$address=pdo_get('core_address',array('isdel'=>0,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
		$address['pcd']=json_decode($address['pcd'],true);
		$return['post']=array('buyjinum'=>1,'addressid'=>$address['id'],'address'=>$address,'simid'=>$return['member']['simid']);
		if(!$return['member']['simid']){
			$return['showsimid']=true;
		}
	}
	$return['pluginset']['alldj_price']=$return['pluginset']['dj_price']+$return['pluginset']['dj_allday']*$return['pluginset']['dj_dayfee'];
	$return['pluginset']['alldj_price2']=$return['pluginset']['dj_price2']+$return['pluginset']['dj_allday2']*$return['pluginset']['dj_dayfee2'];
	//我的小鸡
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$youmid?:$_SESSION['uid']);
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$myjimailist=pdo_getslice('jy_yangjidan_jimai',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($myjimailist){
		$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
		$jiweidata=array(
			array('width'=>100,'top'=>200,'left'=>130),
			array('width'=>80,'top'=>150,'left'=>110),
			array('width'=>80,'top'=>156,'left'=>220),
			array('width'=>40,'top'=>76,'left'=>190),
			array('width'=>100,'top'=>220,'left'=>230),
			array('width'=>55,'top'=>98,'left'=>260),
			array('width'=>55,'top'=>138,'left'=>80),
			array('width'=>100,'top'=>200,'left'=>10),
			array('width'=>65,'top'=>118,'left'=>170),
			array('width'=>55,'top'=>100,'left'=>70),
		);
		foreach($myjimailist as &$item){
			if($item['endtime']<time()){
				$this->model('model')->huigou($item);
				$item['status']=3;
			}
			$item['endday']=date('Y-m-d',$item['endtime']);
			$item['statustitle']=$this->jimai_status[$item['status']];
			$item['width']=rand(50, 130);
			$item['top']=rand(0, 330-$item['width']);
			$item['left']=rand(0, 360-$item['width']);
			$k=rand(0,count($jiweidata)-1);
			$item['width']=$jiweidata[$k]['width'];
			$item['top']=$jiweidata[$k]['top'];
			$item['left']=$jiweidata[$k]['left'];
			unset($jiweidata[$k]);
			$jiweidata=array_values($jiweidata);
		}
	}
	$return['myjimailist']=$myjimailist;
	pdo_update('jy_yangjidan_cvlog',array('status'=>4),array('status'=>3,'endtime <'=>time(),'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$mid=$youmid?:$_SESSION['uid'];
	$sharelink='jy_yangjidan/index//fromuser='.$_SESSION['uid'];
	$title=$member['nickname']?$member['nickname'].'的养鸡农场':$return['pluginset']['share_title'];
	$share_image=$member['avatar']?:$return['pluginset']['share_image'];
	$return['sharedata']=array(
			'title'=>$title?:'首页-养鸡农场',
			'desc'=>$return['pluginset']['share_desc']?$return['pluginset']['share_desc']:'新概念养鸡农场，一个属于自己的农场！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>tomedia($share_image)
	);
	set_html('title',$title?:'养鸡农场');
	exi($return);
}
if($_RQ['op']=='upposter'){
	$openid=$_RQ['openid']?:$_SESSION['openid'];
	$posterset=$this->plugin_setting('poster');
	$member=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','mobile','avatar','nickname'));
	$url=custom_url('jy_yangjidan/index/fromuser='.$_SESSION['uid'],true);
	$qr=cfc('tools')->createqrcode($url,'250',true);
	$qr=tomedia($qr);
	$image='oss/'.$_SESSION['uniacid'].'/images/jy_yangjidan/wxappid'.$_SESSION['uid'].'.jpg';
	$isadd=cfc('files')->source_check($image);
	if(!$isadd && $_SESSION['wxapp_id']){
			$wxappurl='/jy_yangjidan/index/index?fromuser='.$_SESSION['uid'];
			$wxapp=pdo_get('core_account_wxapp',array('id'=>$_SESSION['wxapp_id'],'uniacid'=>$_SESSION['uniacid']));
			$res=model('core/wxapp')->appcode($wxappurl,$wxapp['appid'],$wxapp['appsecret'],200);
			$path='oss/'.$_SESSION['uniacid'].'/images/jy_yangjidan/';
			if(!file_exists(ROOT_AT.$path)){
					mkdir(ROOT_AT.$path,0700, true);
			}
			$filename=$path.'/wxappid'.$_SESSION['uid'].'.jpg';
			$qr=cfc('files')->source_save($res,'image','png','二维码',$filename,'',$wxappurl);
	}
	$return=plugin('jy_poster')->get_active('','','',$openid,$qr,$posterset['data'],'jy_yangjidan');
	$return['posterimg']=$return['poster'];
	exi($return);
}
if($_RQ['op']=='getls_renwu'){
	$type=$_RQ['type'];
	//$msg=$this->model('model')->getls_renwu($type);
	exi($msg);
}
if($_RQ['op']=='getcv_renwu'){
	$type=$_RQ['type'];
	$msg=$this->model('cv')->up_renwu(array(),$type,true);
	exi($msg);
}
if($_RQ['op']=='toweiji'){
	$jiid=$_RQ['jiid'];
	$jiefee=$_RQ['jiefee'];
	$msg=$this->model('model')->toweiji($jiid,$jiefee);
	exi($msg);
}
if($_RQ['op']=='simid'){
	$postdata=get_postdata();
	if(!$postdata['simid']){
		exi('请输入私厨ID！','error');	
	}
	$shoplevelid=pdo_getcolumn('jy_area_psi_level',array('uniacid'=>$_SESSION['uniacid'],'ismerch'=>1),'shoplevelid');
	$shoplevelid2=pdo_getcolumn('jy_weishop_member',array('merchid'=>0,'uniacid'=>$_SESSION['uniacid'],'mid'=>$postdata['simid']),'level');
	if($shoplevelid!=$shoplevelid2){
		exi('该私厨ID不正确，不属于私厨的ID！','error');	
	}
	pdo_update('jy_yangjidan_member',array('simid'=>$postdata['simid']),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	exi('提交成功！','','jy_yangjidan/index/');
}
if($_RQ['op']=='fuhuo'){
	$postdata=get_postdata();
	$id=$_RQ['id'];
	$myji = pdo_get('jy_yangjidan_myji',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	if($myji['status']!=3){
		exi('该蛋鸡不能复活！','error');
	}
	$member = pdo_get('jy_yangjidan_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$lscv=$this->model('cv')->get_lscv();
	$myji['fee']=$myji['type']?$this->setting['cv_fuji2']:$this->setting['cv_fuji'];
	if($myji['fee']>$member['cv']+$lscv){
		exi('可用贡献值不足，不能复活小鸡！','error');
	}
	$this->model('cv')->jian_cv($myji['fee'],$myji['type']?'复活死亡鸡苗消耗':'复活死亡蛋鸡消耗',11);
	$this->model('model')->addjilog($myji,3);
	exi('复活蛋鸡成功！','','jy_yangjidan/index/');
}
if($_RQ['op']=='jimai'){
	$postdata=get_postdata();
	$postdata['type']=$_RQ['type'];
	if($postdata['type']){
		$postdata['jmprice']=$this->setting['dj_saleprice2'];
	}
	$this->model('model')->addjimai($postdata);
	exi('寄卖成功！','','jy_yangjidan/index/');
}
if($_RQ['op']=='tihuo'){
	$postdata=get_postdata();
	$postdata['type']=$_RQ['type'];
	if(!$postdata['tihuonum']){
		exi('请输入提货数量！','error');
	}
	if($postdata['tihuonum']%30 != 0){
		exi('提货数量必须是30的倍数！','error');
	}
	if(!$postdata['address']['pcd']['province'] || !$postdata['address']){
		exi('请填收货地址！','error');
	}
	$postdata['id']=0;
	$postdata['istihuo']=1;
	$postdata['jdnum']=$postdata['tihuonum'];
	$postdata['price']=$this->setting['yunfee'];
	$id=$this->model('model')->myjiorder($postdata);
	if($postdata['price']>0){
			$params=array(
					'id'=>$id,
					'title'=>'提货鸡蛋',
					'fee'=>$postdata['price'],
					'plugin'=>'jy_yangjidan',
					'no_type'=>array('hdfk'),
					'back_url'=>'jy_yangjidan/index/payresulttihuo/',
					'success_url'=>'jy_yangjidan/index/',
					'error_url'=>'jy_yangjidan/index/',
			);
			$payid=cfc('pay')->create_pay_order($params);
			pdo_update('jy_yangjidan_myjiorder',array('uniacid'=>$_SESSION['uniacid'],'payid'=>$payid),array('id'=>$id));
			exi($payid);
	}else{
		pdo_update('jy_yangjidan_myjiorder',array('status'=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
		pdo_update('jy_yangjidan_member',array('jd -='=>$postdata['jdnum']),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
		$order['id']=0;
		$this->model('model')->addjilog($order,10);
		exi('提货成功！');
	}
}
if($_RQ['op']=='buyji'){
	$postdata=get_postdata();
	$jiefee=$_RQ['jiefee'];
	$type=$_RQ['type'];
	$isall=$_RQ['isall'];
	$dj_price=$type?$this->setting['dj_price2']:$this->setting['dj_price'];
	$yang_price=$this->setting['dj_allday']*$this->setting['dj_dayfee'];
	$yang_price2=$this->setting['dj_allday2']*$this->setting['dj_dayfee2'];
	if($isall){
		$dj_price=$type?$yang_price2+$dj_price:$yang_price+$dj_price;
	}
	$postdata['total']=$postdata['buyjinum']?:1;
	$postdata['price']=$dj_price*$postdata['total'];
	$postdata['jitype']=$type;
	$postdata['isall']=$isall;
	$id=$this->model('model')->upfeelog($postdata,0,$jiefee);
	if($postdata['price']>0 && !$jiefee){
			$params=array(
					'id'=>$id,
					'title'=>$type?'认养鸡苗':'租养蛋鸡',
					'fee'=>$postdata['price'],
					'plugin'=>'jy_yangjidan',
					'no_type'=>array('hdfk'),
					'back_url'=>'jy_yangjidan/index/payresult/',
					'success_url'=>'jy_yangjidan/index/',
					'error_url'=>'jy_yangjidan/index/',
			);
			$payid=cfc('pay')->create_pay_order($params);
			pdo_update('jy_yangjidan_feelog',array('uniacid'=>$_SESSION['uniacid'],'payid'=>$payid),array('id'=>$id));
			$res=array(
				'pay_id'=>$payid,
				'order_id'=>$id,
			);
			exi($res);
	}elseif($jiefee){
		$order=pdo_get('jy_yangjidan_feelog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		$this->model('model')->addmyji($order);
		exi('赊账认养成功！');
	}else{
		exi('认养失败，蛋鸡价格未设置！');
	}
}
if($_RQ['op']=='weituo'){
	$postdata=get_postdata();
	$item=pdo_get('jy_yangjidan_myji',array('uniacid'=>$_SESSION['uniacid'],'id'=>$postdata['jiid']));
	$dj_dayfee=$this->setting['dj_dayfee']?:0.8;
	$dj_allday=$this->setting['dj_allday']?:120;
	$item['lastday']=$dj_allday-$item['lsday'];
	$item['lastday']=$item['lastday']>0?$item['lastday']:0;
	$allfee=$dj_dayfee*$item['lastday'];
	$postdata['price']=$allfee;
	$postdata['total']=$item['lastday'];
	$id=$this->model('model')->upfeelog($postdata,2);
	if($allfee>0){
			$params=array(
					'id'=>$id,
					'title'=>'委托平台投喂',
					'fee'=>$allfee,
					'plugin'=>'jy_yangjidan',
					'no_type'=>array('hdfk'),
					'back_url'=>'jy_yangjidan/index/payresult/',
					'success_url'=>'jy_yangjidan/index/',
					'error_url'=>'jy_yangjidan/index/',
			);
			$payid=cfc('pay')->create_pay_order($params);
			pdo_update('jy_yangjidan_feelog',array('uniacid'=>$_SESSION['uniacid'],'payid'=>$payid),array('id'=>$id));
			$res=array(
				'pay_id'=>$payid,
				'order_id'=>$id,
			);
			exi($res);
	}else{
		exi('购买失败，蛋鸡价格未设置！');
	}
}
if($_RQ['op']=='cvdui'){
	$postdata=get_postdata();
	if($postdata['jidannum']<=0){
		exi('请输入兑换鸡蛋件数！','error');	
	}
	if(!$postdata['address']['pcd']['province'] || !$postdata['address']){
		exi('请填收货地址！','error');
	}
	$cv=pdo_getcolumn('jy_yangjidan_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'cv');
	if($postdata['cvfee']>$cv){
		exi('当前剩余CV不足！','error');	
	}
	$data=array(
			'price'=>0,
			'jifen2'=>0,
			'jdnum'=>$postdata['jidannum']*30,
			'type'=>0,
			'status'=>1,
			'istihuo'=>$postdata['istihuo'],
			'name'=>$postdata['address']['name'],
			'mobile'=>$postdata['address']['mobile'],
			'address'=>$postdata['address'],
	);
	$id=$this->model('model')->myjiorder($data);
	pdo_update('jy_yangjidan_member',array('cv -='=>$postdata['cvfee']),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	pdo_update('jy_yangjidan_myjiorder',array('status'=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	$this->model('cv')->jian_cv($postdata['cvfee'],'购买鸡蛋消耗',9);
	exi('兑换成功！','','jy_yangjidan/index/');
}
if($_RQ['op']=='payresult'){
	$payresult=$_SESSION['pay_result'];
	if(!$payresult){
		exi('支付失败，未收到支付结果！','error','main');
	}
	if($payresult['status']!=1){
		exi('支付失败！','error','main');
	}
	$order=pdo_get('jy_yangjidan_feelog',array('id'=>$payresult['id'],'uniacid'=>$_SESSION['uniacid']));
	if(!$order){
		exi('支付失败！指定订单不存在！','error');
	}
	if($order['status']){
		exi('订单已支付，无需重复支付！','error');
	}
	if($order['price']!=$payresult['fee']){
		exi('支付失败！订单金额不匹配！','error');
	}
	pdo_update('jy_yangjidan_feelog',array('status'=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$payresult['id']));
	if($order['type']==1){
		$lsfee=$order['total']*1000;
	}elseif($order['type']==2){
		pdo_update('jy_yangjidan_myji',array('isweitou'=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$order['jiid']));
	}elseif($order['type']==3){
		pdo_update('jy_yangjidan_feelog',array('status'=>1),array('status'=>0,'jiefee'=>1,'mid'=>$order['mid'],'uniacid'=>$_SESSION['uniacid']));
	}elseif(!$order['type']){
		$this->model('model')->addmyji($order);
	}
	model('jy_area_psi/cv')->buyji($order);
	exi('支付成功','success','jy_yangjidan/index/');
}
if($_RQ['op']=='payresulttihuo'){
	$payresult=$_SESSION['pay_result'];
	if(!$payresult){
		exi('支付失败，未收到支付结果！','error','main');
	}
	if($payresult['status']!=1){
		exi('支付失败！','error','main');
	}
	$order=pdo_get('jy_yangjidan_myjiorder',array('id'=>$payresult['id'],'uniacid'=>$_SESSION['uniacid']));
	if(!$order){
		exi('支付失败！指定订单不存在！','error');
	}
	if($order['status']){
		exi('订单已支付，无需重复支付！','error');
	}
	if($order['price']!=$payresult['fee']){
		exi('支付失败！订单金额不匹配！','error');
	}
	pdo_update('jy_yangjidan_myjiorder',array('status'=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$payresult['id']));
	pdo_update('jy_yangjidan_member',array('jd -='=>$order['jdnum']),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$order['mid']));
	$order['id']=0;
	$this->model('model')->addjilog($order,10);
	exi('支付成功','success','jy_yangjidan/myjiorder/');
}
if($_RQ['op']=='payjifee'){
	$postdata=get_postdata();
	$jiefee=$this->model('model')->checkjiefee(0,true);
	$postdata['price']=$jiefee;
	$id=$this->model('model')->upfeelog($postdata,3);
	if($jiefee>0){
			$params=array(
					'id'=>$id,
					'title'=>'付清赊账',
					'fee'=>$jiefee,
					'plugin'=>'jy_yangjidan',
					'no_type'=>array('hdfk'),
					'back_url'=>'jy_yangjidan/index/payresult/',
					'success_url'=>'jy_yangjidan/index/',
					'error_url'=>'jy_yangjidan/index/',
			);
			$payid=cfc('pay')->create_pay_order($params);
			pdo_update('jy_yangjidan_feelog',array('uniacid'=>$_SESSION['uniacid'],'payid'=>$payid),array('id'=>$id));
			$res=array(
				'pay_id'=>$payid,
				'order_id'=>$id,
			);
			exi($res);
	}else{
		exi('购买失败，不存在赊账费用！');
	}
}
